#ifndef LabviewConverter_h
#define LabviewConverter_h 1

#include <marlin/DataSourceProcessor.h>
//#include "LConverter.hh"
#include "IMPL/LCEventImpl.h" 
#include "IMPL/LCRunHeaderImpl.h" 
#include "UTIL/LCTime.h"
#include "IMPL/LCGenericObjectImpl.h"
#include "IMPL/LCCollectionVec.h"

#include "lccd.h"
#include "lccd/DBInterface.hh"

//using namespace lcio ;


namespace marlin{
  
  /** Processor for reading the AHCAL Labview asscii files.   
   *  It processes the input data to create events with LCIO collections
   *  of the AHCAL Labview ascii output.
   *  Based on F. Gaede's StdHepReader to be found in the marlin package. 
   *  @author: S. Lu (DESY Hamburg)
   *  @date Aug 15 2012
   */
  
  class LabviewConverter : public DataSourceProcessor {
    
  public:

    LabviewConverter() ;

    /** Implementation of new Processor 
      * returns pointer to processor  
      */
    virtual LabviewConverter*  newProcessor() ;


    /** Creates events with LCGenrealObject collections from the Labview input file and
     *  calls all active processors' processEvent() and processRunHeader Method.
     */
    virtual void readDataSource( int numEvents ) ;
    

    
    /** init method */
    virtual void init() ;

    /** end method */
    virtual void end() ;
    
  protected:
    
    /** The string variable to access the data. Requires
	"yourpath/Run" */
    //std::string _dataPath ;
    std::string _ofile ;

    /** The string variable to access the data. Requires
	"yourpath/Run" */
    std::string _data ;

    /** The run number */
    int _runNumber;

    /** The HBU number: HBUVI: 6; HBUVI: 7, HBUVIII: 8, HBUIX: 9. */
    int _HBUNumber;

    /** The string variable to access the mapping. Requires
	"yourpath/map" */
    std::string _mapping ;


    /** The bool variable to read HBU mapping from database */
    bool _useDBMapping;

   /** The string variable for the CALICE database. Requires
	"flccaldb02.desy.de:calice:caliceon:Delice.1:3306" */
    std::string _dbinit ;

    /** The string variable for the database folder name . Requires
	"/database/folder/nameMapping" */
    std::string _dbfolder ;


    /** The string variable for the database folder tag . Requires
	"HEAD" */
    std::string _tag;


    /** The lccd::LCCDTimeStamp variable for the database folder timestamp . Requires
	"1343779200000000001LL" */
//    lccd::LCCDTimeStamp _timeStamp;
//    lcio::long64 _timeStamp;
    std::string _timeStamp;

    /**The variable which decides whether buffering has to be switched
      *on or off
      */
    int _bufferingEnabled;

    //private:
    
    //LABVIEWDAQ::LConverter _lConverter; /*auxiliary class which create LCEvents from the Labview records.*/

  };
 
} // end namespace marlin 

#endif
